package com.sxdx.service.impl;

import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;
import com.sxdx.dao.OrderinfoDAO;
import com.sxdx.entity.Orderinfo;
import com.sxdx.service.OrderinfoService;

@Service("orderinfoService")
@SuppressWarnings("all")
public class OrderinfoServiceImpl implements OrderinfoService {
	private static Logger logger = LogManager.getLogger(Thread.currentThread().getStackTrace()[1].getClassName());
	@Resource(name = "orderinfoDAO")
	private OrderinfoDAO orderinfoDAO;

	public void order(Orderinfo orderinfo) {
		orderinfoDAO.save(orderinfo);
	}

	public List<Orderinfo> orderinfo(int week) {
		String hql = "from Orderinfo o where o.OWeek=?";
		List<Object> param = new ArrayList<Object>();
		param.add(week);
		return orderinfoDAO.find(hql, param);
	}

	public void clearOrder() {
		String hql = "from Orderinfo";
		List<Orderinfo> l = orderinfoDAO.find(hql);
		for (Orderinfo orderinfo : l) {
			orderinfoDAO.delete(orderinfo);
		}
	}

	public void deleteOrder(Orderinfo o) {
		orderinfoDAO.delete(o);
	}

	public List<Orderinfo> finddeleteOrder(String date, String type, String name) {
		String hql = "from Orderinfo o where o.ODate=? and o.OType=? and o.OTeacherName=?";
		List<Object> param = new ArrayList<Object>();
		param.add(date);
		param.add(Integer.parseInt(type));
		param.add(name);
		List<Orderinfo> l = orderinfoDAO.find(hql, param);
		return l;
	}
}
